/**
 * Created by John on 2016/7/8.
 */
var selfie = {
    word: 'selfie',
    first: 's',
    last: 'e',
    size: 6,
    letters: ['s', 'e', 'l', 'f', 'i'],
    stats: {vowels: 3, consonants: 3},
    charsets: [
        {type: 'consonants', chars: ['s', 'l', 'f']},
        {type: 'vowels', chars: ['e', 'i']}
    ],
    category: 'New'
};

var tweet = {
    word: 'tweet',
    first: 't',
    last: 't',
    size: 4,
    letters: ['t', 'w', 'e'],
    stats: {vowels: 2, consonants: 3},
    charsets: [
        {type: 'consonants', chars: ['t', 'w']},
        {type: 'vowels', chars: ['e']}
    ],
    category: 'New'
};

var google = {
    word: 'google',
    first: 'g',
    last: 'e',
    size: 6,
    letters: ['g', 'o', 'l', 'e'],
    stats: {vowels: 3, consonants: 3},
    charsets: [
        {type: 'consonants', chars: ['g', 'l']},
        {type: 'vowels', chars: ['o', 'e']}
    ],
    category: 'New'
};

var mongo = new Mongo("localhost");
var wordsDB = mongo.getDB("BeginningMongoDB");
wordsColl = wordsDB.getCollection("word_stats");

wordsDB.runCommand({getLastError: 1, w: 1, j: true, wtimeout: 1000});

var query = {word: {$in: ['tweet', 'google', 'selfie']}};
var projection = {word: 1};
print('Before Inserting selfie:');
var cursor = wordsColl.find(query, projection);
printjson(cursor.toArray());

print('After Inserting selfie');
wordsColl.insert(selfie);
cursor = wordsColl.find(query, projection)
printjson(cursor.toArray());

print('After Inserting tweet and google');
wordsColl.insert([tweet,google]);
cursor = wordsColl.find(query, projection)
printjson(cursor.toArray());